<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="clienteSearch" styleClass="edit">

        <rich:simpleTogglePanel label="Cliente Search Filter" switchType="ajax">

            <s:decorate template="layout/display.xhtml">
                <ui:define name="label">Apellido</ui:define>
                <h:inputText id="apellido" value="#{clienteList.cliente.apellido}"/>
            </s:decorate>

            <s:decorate template="layout/display.xhtml">
                <ui:define name="label">Celular</ui:define>
                <h:inputText id="celular" value="#{clienteList.cliente.celular}"/>
            </s:decorate>

            <s:decorate template="layout/display.xhtml">
                <ui:define name="label">Direccion</ui:define>
                <h:inputText id="direccion" value="#{clienteList.cliente.direccion}"/>
            </s:decorate>

            <s:decorate template="layout/display.xhtml">
                <ui:define name="label">Email</ui:define>
                <h:inputText id="email" value="#{clienteList.cliente.email}"/>
            </s:decorate>

            <s:decorate template="layout/display.xhtml">
                <ui:define name="label">Nombre</ui:define>
                <h:inputText id="nombre" value="#{clienteList.cliente.nombre}"/>
            </s:decorate>

            <s:decorate template="layout/display.xhtml">
                <ui:define name="label">Numero documento</ui:define>
                <h:inputText id="numeroDocumento" value="#{clienteList.cliente.numeroDocumento}"/>
            </s:decorate>

            <s:decorate template="layout/display.xhtml">
                <ui:define name="label">Telefono fijo</ui:define>
                <h:inputText id="telefonoFijo" value="#{clienteList.cliente.telefonoFijo}"/>
            </s:decorate>

            <s:decorate template="layout/display.xhtml">
                <ui:define name="label">Match</ui:define>
                <h:selectOneRadio id="logic" value="#{clienteList.restrictionLogicOperator}" styleClass="radio">
                    <f:selectItem itemLabel="All" itemValue="and"/>
                    <f:selectItem itemLabel="Any" itemValue="or"/>
                </h:selectOneRadio>
            </s:decorate>

        </rich:simpleTogglePanel>

        <div class="actionButtons">
            <h:commandButton id="search" value="Search" action="/ClienteList.xhtml"/>
            <s:button id="reset" value="Reset" includePageParams="false"/>
        </div>

    </h:form>

    <rich:panel>
        <f:facet name="header">Cliente Search Results (#{empty clienteList.resultList ? 0 : (clienteList.paginated ? clienteList.resultCount : clienteList.resultList.size)})</f:facet>
    <div class="results" id="clienteList">

    <h:outputText value="The cliente search returned no results."
               rendered="#{empty clienteList.resultList}"/>

    <rich:dataTable id="clienteList"
                var="_cliente"
              value="#{clienteList.resultList}"
           rendered="#{not empty clienteList.resultList}">
        <h:column>
            <f:facet name="header">
                <ui:include src="layout/sort.xhtml">
                    <ui:param name="entityList" value="#{clienteList}"/>
                    <ui:param name="propertyLabel" value="Id"/>
                    <ui:param name="propertyPath" value="cliente.id"/>
                </ui:include>
            </f:facet>
            <h:outputText value="#{_cliente.id}"/>
        </h:column>
        <h:column>
            <f:facet name="header">
                <ui:include src="layout/sort.xhtml">
                    <ui:param name="entityList" value="#{clienteList}"/>
                    <ui:param name="propertyLabel" value="Apellido"/>
                    <ui:param name="propertyPath" value="cliente.apellido"/>
                </ui:include>
            </f:facet>
            <h:outputText value="#{_cliente.apellido}"/>
        </h:column>
        <h:column>
            <f:facet name="header">
                <ui:include src="layout/sort.xhtml">
                    <ui:param name="entityList" value="#{clienteList}"/>
                    <ui:param name="propertyLabel" value="Celular"/>
                    <ui:param name="propertyPath" value="cliente.celular"/>
                </ui:include>
            </f:facet>
            <h:outputText value="#{_cliente.celular}"/>
        </h:column>
        <h:column>
            <f:facet name="header">
                <ui:include src="layout/sort.xhtml">
                    <ui:param name="entityList" value="#{clienteList}"/>
                    <ui:param name="propertyLabel" value="Direccion"/>
                    <ui:param name="propertyPath" value="cliente.direccion"/>
                </ui:include>
            </f:facet>
            <h:outputText value="#{_cliente.direccion}"/>
        </h:column>
        <h:column>
            <f:facet name="header">
                <ui:include src="layout/sort.xhtml">
                    <ui:param name="entityList" value="#{clienteList}"/>
                    <ui:param name="propertyLabel" value="Email"/>
                    <ui:param name="propertyPath" value="cliente.email"/>
                </ui:include>
            </f:facet>
            <h:outputText value="#{_cliente.email}"/>
        </h:column>
        <h:column>
            <f:facet name="header">
                <ui:include src="layout/sort.xhtml">
                    <ui:param name="entityList" value="#{clienteList}"/>
                    <ui:param name="propertyLabel" value="Nombre"/>
                    <ui:param name="propertyPath" value="cliente.nombre"/>
                </ui:include>
            </f:facet>
            <h:outputText value="#{_cliente.nombre}"/>
        </h:column>
        <h:column>
            <f:facet name="header">
                <ui:include src="layout/sort.xhtml">
                    <ui:param name="entityList" value="#{clienteList}"/>
                    <ui:param name="propertyLabel" value="Numero documento"/>
                    <ui:param name="propertyPath" value="cliente.numeroDocumento"/>
                </ui:include>
            </f:facet>
            <h:outputText value="#{_cliente.numeroDocumento}"/>
        </h:column>
        <h:column>
            <f:facet name="header">
                <ui:include src="layout/sort.xhtml">
                    <ui:param name="entityList" value="#{clienteList}"/>
                    <ui:param name="propertyLabel" value="Telefono fijo"/>
                    <ui:param name="propertyPath" value="cliente.telefonoFijo"/>
                </ui:include>
            </f:facet>
            <h:outputText value="#{_cliente.telefonoFijo}"/>
        </h:column>
        <h:column>
            <f:facet name="header">
                <ui:include src="layout/sort.xhtml">
                    <ui:param name="entityList" value="#{clienteList}"/>
                    <ui:param name="propertyLabel" value="Tipo documento id"/>
                    <ui:param name="propertyPath" value="cliente.tipoDocumento.id"/>
                </ui:include>
            </f:facet>
            <h:outputText value="#{_cliente.tipoDocumento.id}"/>
        </h:column>
        <rich:column styleClass="action">
            <f:facet name="header">Action</f:facet>
            <s:link view="/#{empty from ? 'Cliente' : from}.xhtml"
                   value="#{empty from ? 'View' : 'Select'}"
             propagation="#{empty from ? 'none' : 'default'}"
                      id="clienteViewId">
                <f:param name="clienteId"
                        value="#{_cliente.id}"/>
            </s:link>
            #{' '}
            <s:link view="/ClienteEdit.xhtml"
                   value="Edit"
             propagation="none"
                      id="clienteEdit"
                rendered="#{empty from}">
                <f:param name="clienteId"
                        value="#{_cliente.id}"/>
            </s:link>
        </rich:column>
    </rich:dataTable>

    </div>
    </rich:panel>

    <div class="tableControl">

        <s:link view="/ClienteList.xhtml"
            rendered="#{clienteList.previousExists}"
               value="#{messages.left}#{messages.left} First Page"
                  id="firstPage">
          <f:param name="firstResult" value="0"/>
        </s:link>

        <s:link view="/ClienteList.xhtml"
            rendered="#{clienteList.previousExists}"
               value="#{messages.left} Previous Page"
                  id="previousPage">
            <f:param name="firstResult"
                    value="#{clienteList.previousFirstResult}"/>
        </s:link>

        <s:link view="/ClienteList.xhtml"
            rendered="#{clienteList.nextExists}"
               value="Next Page #{messages.right}"
                  id="nextPage">
            <f:param name="firstResult"
                    value="#{clienteList.nextFirstResult}"/>
        </s:link>

        <s:link view="/ClienteList.xhtml"
            rendered="#{clienteList.nextExists}"
               value="Last Page #{messages.right}#{messages.right}"
                  id="lastPage">
            <f:param name="firstResult"
                    value="#{clienteList.lastFirstResult}"/>
        </s:link>

    </div>

    <s:div styleClass="actionButtons" rendered="#{empty from}">
        <s:button view="/ClienteEdit.xhtml"
                    id="create"
           propagation="none"
                 value="Create cliente">
            <f:param name="clienteId"/>
        </s:button>
    </s:div>

</ui:define>

</ui:composition>
